package driver

import (
	"fmt"
	"gitee.com/xluomo945/fm/context"
	"gitee.com/xluomo945/fm/helper"
	"gitee.com/xluomo945/fm/setting"
	"github.com/gin-gonic/gin"
	"os"
	"time"
)

// 创建DB名称
func name(config setting.LoggerConfig) string {
	if !config.ByDay {
		return fmt.Sprintf("%s%s%s", config.Dir, string(os.PathSeparator), config.Name)
	}
	current := time.Now().Format("2006-01-02")
	return fmt.Sprintf("%s%s%s_%s", config.Dir, string(os.PathSeparator), config.Name, current)
}

// 获取链路ID
func trace(ctx *gin.Context) string {
	str := context.GetTradeID(ctx)
	if helper.StringEmpty(str) {
		str = "00000000000000000000000000000000"
	}
	return str
}
